﻿<%@ include file="../include/top.jsp"%>
<%@ include file="../include/errorArea.jsp"%>
<%@ include file="../include/message-save.jsp" %>
<div class='adduser'>
	<div class='adduser-left'><div class='adduser-icon'></div><span>注册会员</span></div>
</div>
<div class='querycondition'>
	<div class='condtion'>
<div align="center" id="codeArea">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1">
			 <tr>
   				<td>
			    	小区：<select name="community" id="community" style="width:100px" onchange="checkBuilding('${ctx}');">
			    		<c:forEach var="com" items="${communityList}">
				      		<option value="${com.id}">${com.communityName}</option>
				      	</c:forEach>
			    	</select>楼号：<select name="buildNo" id="buildNo" style="width:100px" onchange="checkUnit('${ctx}');">
			    	<option value="">请选择</option>
			    	<c:forEach var="build" items="${buildingList}">
				      		<option value="${build.id}">${build.buildingCode}</option>
				      	</c:forEach>
			    	</select>单元号：
			    	<select name="unitNo" id="unitNo" style="width:100px" onchange="checkRoom('${ctx}');"></select>
			    	门牌号：<select name="roomNo" id="roomNo" style="width:100px"></select>
			  
<input type="button" name="login" onclick="validateCode()" value="确定" class="button cyan medium"/>
  			</td></tr>
		</table>
</div><br/><br/>

<p align="center">
<%@ include file="../include/errorArea.jsp" %>
</p>
<form method="post" name="saveForm" action="${baseURL}/companyAdmin/reg" onsubmit="return checkInput()">
<input type="hidden" name="roomId" id="roomId_form" value="${formdata.roomId}"/>
<input type="hidden" name="userType" id="userType_form" value="${formdata.userType}"/>
<input type="hidden" name="companyType" id="companyType" value="${companyType}"/>
<table id="regTable" border="0" cellpadding="4" cellspacing="0" align="center" style="display:none">
   	<tbody>
   		<!-- <tr>
       	<td class="t2"><font color="red">*</font>用户名：</td>
           <td>
           	<input type="text" class="input-login-03" name="username" id="username" value="${formdata.username}" maxlength="50" >
           </td>
       </tr> -->
      <tr>
       	<td class="t2"><font color="red">*</font>手机号：(手机号即为用户名)</td>
           <td>
           		<input type="text" class="input-login-03" name="mobile" id="mobile" value="${formdata.mobile}" maxlength="16" >
           </td>
       </tr>
       <tr>
       	<td class="t2"><font color="red">*</font>姓名：</td>
           <td>
           		<input type="text" class="input-login-03" name="realName" id="realName" value="${formdata.realName}" maxlength="16" >
           </td>
       </tr>
       <c:if test="${sessionScope.community.communityType==2}">
        <tr id="row_oneCardNo">
			       	<td class="t2">一卡通号码：</td>
			           <td>
			           		<input type="text" class="input-login-03" name="oneCardNo" id="oneCardNo" maxlength="10" value="${formdata.oneCardNo}"/>
			           </td>
			       </tr>
			  <!--     <tr id="row_oneCardNo2">
			       	<td class="t2"><font color="red">*</font>一卡通号码确认：</td>
			           <td>
			           		<input type="text" class="input-login-03" name="oneCardNo2" id="oneCardNo2" maxlength="10" value="${formdata.oneCardNo}"/>
			           </td>
			       </tr>-->
        </c:if>  
        <tr>
       	<td class="t2">电子邮箱：</td>
           <td>
           		<input type="text" class="input-login-03" name="email" id="email" value="${formdata.email}" maxlength="100" >
           </td>
       </tr>
       <tr>
			       	<td class="t2">QQ：</td>
			           <td>
			           		<input type="text" class="input-login-03" name="qq" id="qq" value="${formdata.qq}" maxlength="20" />
			           </td>
			       </tr>
			       <tr>
			       	<td class="t2">微信：</td>
			           <td>
			           		<input type="text" class="input-login-03" name="microMsg" id="microMsg" value="${formdata.microMsg}" maxlength="50" />
			           </td>
			       </tr>
       <tr>
       	<td class="t2">固定电话：</td>
           <td>
           		<input type="text" class="input-login-03" name="telephone" id="telephone" value="${formdata.telephone}" maxlength="16" >
           </td>
       </tr>
       
       <tr>
       	<td class="t2">出生日期：</td>
           <td>
           <input id="birthday" name="birthday" onclick="calendar.show(this);" value="${formdata.birthday}" type="text" class="input-login-03">
                
           </td>
       </tr>
       <tr>
       	<td class="t2">性别：</td>
           <td>
           		<label><input type="radio" name="sex" value="0" <c:if test="${formdata.sex=='0'}">checked</c:if>> 男</label>
                <label><input type="radio" name="sex" value="1" <c:if test="${formdata.sex=='1'}">checked</c:if>> 女</label>
           </td>
       </tr>
       <tr>
       	<td class="t2">家庭人数：</td>
           <td>
           		<input type="text" class="input-login-03" name="familyNumber" id="familyNumber" maxlength="16" value="${formdata.familyNumber}">
           </td>
       </tr>
       <tr>
       	<td class="t2">职业：</td>
           <td>
           		<input type="text" class="input-login-03" name="occupation" id="occupation" maxlength="16" value="${formdata.occupation}">
           </td>
       </tr>
       <tr>
       	<td class="t2">兴趣爱好：</td>
           <td>
           		<input type="text" class="input-login-03" name="interest" id="interest" maxlength="16" value="${formdata.interest}">
           </td>
       </tr>
        <tr>
       	<td class="t2"><font color="red">*</font>密码：</td>
           <td>
           		<input type="password" class="input-login-03" name="pw" id="password" value="${formdata.pw}" maxlength="16" >
           </td>
       </tr>
       <tr>
       	<td class="t2"><font color="red">*</font>确认密码：</td>
           <td>
           		<input type="password" class="input-login-03" name="pw2" id="password2" value="${formdata.pw2}" maxlength="16" >
           </td>
       </tr>
       <tr>
       	<td>&nbsp;</td>
           <td><input type="submit" name="login" value="注册"  class='button cyan medium'/>
        </td>
        </tr>
    </tbody>
</table>
</form>

<script>

//验证注册码
function validateCode(){
	var room = document.getElementById("roomNo");
	var roomNo = room.options[room.selectedIndex].value;
	if(roomNo==""){
		alert("请选择房间。");
		return false;
	}
	
	//ajax验证
	var url="${ctx}"+"/companyAdmin/validateCode";
	$.post(url,{"code":roomNo},function(data){
		if(data.result=='NG'){
			alert(data.message);
			return;
		}
		var msg = "该房间编码对应的地址为[" + data.message + "]，如果正确，请点击确认开始注册。\n如果不正确，请联系服务站取得正确的房间编码。";
		if(confirm(msg)){
			$("#codeArea").hide(1000);
			$("#regTable").show(1000);
			$("#bindCode").val(roomNo);
		}
	},'json');
}


//检查输入
function checkInput(){

	var password = document.getElementById("password");
	if(password.value==""){
		alert("请输入密码。");
		password.focus();
		return false;
	}
	//校区，要检查一卡通号码
	var typeValue = $("#userType_form").val();
	/*if(typeValue==2){
		if($("#oneCardNo").val()==""){
			alert("请输入一卡通号码。");
			$("#oneCardNo").focus();
			return false;
		}
		if($("#oneCardNo2").val()==""){
			alert("请确认一卡通号码。");
			$("#oneCardNo2").focus();
			return false;
		}
		if($("#oneCardNo").val()!=$("#oneCardNo2").val()){
			alert("两次输入的一卡通号码不一致。");
			$("#oneCardNo").focus();
			return false;
		}
	}*/
	var password2 = document.getElementById("password2");
	if(password2.value==""){
		alert("请输入确认密码。");
		password2.focus();
		return false;
	}
	if(password.value != password2.value){
		alert("两次输入的密码不一致。");
		password2.focus();
		return false;
	}
	var realName = document.getElementById("realName");
	if(realName.value==""){
		alert("请输入真实姓名。");
		realName.focus();
		return false;
	}
	var mobile = document.getElementById("mobile");
	if(mobile.value==""){
		alert("请输入手机。");
		mobile.focus();
		return false;
	}
	var isMobile=/^1\d{10}$/; 
	if(!isMobile.test(mobile.value)){
		alert("手机号码应为11位数字。");
		mobile.focus();
		return false;
	}
	return true;
}
</script>
<script src="${ctx}/js/buyProduct.js"></script>
<c:if test="${sessionScope.community.communityType==2}">
<script>
$('#userType_form').val(2);
$("#codeArea").hide();
$("#regTable").show();
</script>
</c:if>
<c:if test="${formdata.bindCode!=null}">
<script>
$("#codeArea").hide();
$("#regTable").show();
</script>
</c:if>
</div>
</div>
